package com.example.testactivity0316;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import android.content.Intent;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;


public class ThirdActivity3 extends AppCompatActivity {
    public Button back3;


        public LinearLayout linearlayout;

        public ImageView main_imageview;

        public int i =0;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_third3);

        initView();
    }
/*
        Timer timer = new Timer();

        public Handler handler;

    {
        handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {

                Log.e("@@@", i + "");
                //index=msg.what;
                if (i > 6) {
                    i = 0;
                } else {
                    switch (i) {
                        case 1:
                            main_imageview.setImageResource(R.drawable.photo01);
                            break;
                        case 2:
                            main_imageview.setImageResource(R.drawable.photo02);
                            break;
                        case 3:
                            main_imageview.setImageResource(R.drawable.photo03);
                            break;
                        case 4:
                            main_imageview.setImageResource(R.drawable.photo01);
                            break;
                        case 5:
                            main_imageview.setImageResource(R.drawable.photo02);
                            break;
                        case 6:
                            main_imageview.setImageResource(R.drawable.photo03);
                            break;
                        default:
                            break;
                    }
                    linearlayout.invalidate();
                }
                super.handleMessage(msg);
            }
        };
    }*/

        public void initView()
        {
            back3=findViewById(R.id.back3);
            back3.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent intent = new Intent(ThirdActivity3.this,MainActivity.class);
                    startActivity(intent);
                }
            });

            //linearlayout = (LinearLayout) findViewById(R.id.add_item);
            //main_imageview = (ImageView) findViewById(R.id.button3);

     /*       timer.scheduleAtFixedRate(new TimerTask()
            {
                @Override
                public void run()
                {
                    // TODO Auto-generated method stub
                    i++;
                    Message mesasge = new Message();
                    mesasge.what = i;
                    handler.sendMessage(mesasge);
                }
            }, 0, 500);
        }

        @Override
        protected void onDestroy()
        {
            // TODO Auto-generated method stub
            timer.cancel();
            super.onDestroy();*/
        }
    }
